<?php 
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../DAO/NewsletterDAO.php';
class NewsletterService
{
	public function create(BaseContext $context, ServiceResult $result, NewsletterDomain $newsletterDomain)
	{
		try
		{
			$newsletterDAO = new NewsletterDAO($context);
			$newsletterDAO->create($newsletterDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function update(BaseContext $context, ServiceResult $result, NewsletterDomain $newsletterDomain)
	{
		try
		{
			$newsletterDAO = new NewsletterDAO($context);
			$newsletterDAO->update($newsletterDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function delete(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$newsletterDAO = new NewsletterDAO($context);
			$newsletterDAO->delete($oid);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findByOid(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$newsletterDAO = new NewsletterDAO($context);
			$newsletterDomain = $newsletterDAO->findByOid($oid);
			$result->setSuccess();
			return $newsletterDomain;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findAll(BaseContext $context, ServiceResult $result)
	{
		try
		{
			$newsletterDAO = new NewsletterDAO($context);
			$newsletterDomainArr = $newsletterDAO->findAll();
			$result->setSuccess();
			return $newsletterDomainArr;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

}
?>